<?php
// constants.php
require_once (dirname(__FILE__)."/../General/Util.php");
//if($_SERVER['SERVER_NAME']=="localhost"){
//    define("LOCAL_MODE",true);
//}
//else {
//    define("LOCAL_MODE",false);    
//}
define("LOCAL_MODE",true);
define("TRIAL_PERIOD", 30);
$session_host = '';

$env = array();

// SALESFORCE
define("CP_ORG_USERNAME", "mustafa.gsync@cirruscg.com");
define("CP_ORG_PASSWORD", 'Manage785');
define("CP_ORG_SECTOKEN", 'o5w30kX0d8BXSyfNHVON5X7f2');

if(LOCAL_MODE==false){
    

    // DATABASE
    define("REDIS_HOST", $env["DOTCLOUD_REDIS_REDIS_HOST"]);
    define("REDIS_PORT", $env["DOTCLOUD_REDIS_REDIS_PORT"]);
    define("REDIS_PASS", $env["DOTCLOUD_REDIS_REDIS_PASSWORD"]);

    define("FE_INSTANCE", $env["DOTCLOUD_SERVICE_ID"]);
} else {
    $env["DOTCLOUD_PROJECT"]= "local";
    $env["VERSION"]= "1.3.000";    
}

define("SESSION_HOST", '.dotcloud.com');
$webhost = "https://calender-mubashar.dotcloud.com/";
define("SFDC_OAUTH_CLIENT_ID", '3MVG9rFJvQRVOvk43P2T87EaAleO_HScYoS2ANPUX2muEWN5Bxg8JcM8dNeDcOtnh1EjaSsiiTMHJG1Zkw3bW');
define("SFDC_OAUTH_SECRET", '2864065452113985955');

define("SFDC_OAUTH_REDIRECT_URI", $webhost.'sfdcLogin.php');

session_set_cookie_params(
	$lifetime=(60*60*4), // 4 hours
	'/', // path
	SESSION_HOST,
	true, // secure only
	true // http only (cannot be retrieved by javascript)
);

define("CURRENT_VERSION", $env["VERSION"]);
// Initiate a new session if they haven't since the newest version was released
if (!array_key_exists("ci_version", $_SESSION) || $_SESSION["ci_version"] != CURRENT_VERSION) {
//	Util::logout(true); // kills the SSO token
	Util::logout(); // keeps the SSO token
	
	//session_start();
	$_SESSION["ci_version"] = CURRENT_VERSION;
}

define("SFDC_CLIENT_ID", "Cirruspath/Insight/");

define("CRYPT_IV", substr(SFDC_OAUTH_SECRET, 0, 16));
define("API_VERSION", '20.0');

// SALESFORCE OAUTH
if (array_key_exists("custom_login_url", $_COOKIE) && isset($_COOKIE["custom_login_url"])) {
	// If they use My Domain or SSO, they'll hit a different URL
	define("SALESFORCE_HOST", urldecode($_COOKIE["custom_login_url"]));
} else {
	define("SALESFORCE_HOST", "https://login.salesforce.com/");
}

$oauth_token_scope = "full%20refresh_token";
define('SFDC_AUTH_CODE_URL', SALESFORCE_HOST . 'services/oauth2/authorize?response_type=code&client_id='.SFDC_OAUTH_CLIENT_ID.'&redirect_uri=' . urlencode(SFDC_OAUTH_REDIRECT_URI) . '&display=popup&scope='.$oauth_token_scope.'&code=');
define('SFDC_ACCESS_TOKEN_URL', SALESFORCE_HOST . 'services/oauth2/token?grant_type=authorization_code&client_id='.SFDC_OAUTH_CLIENT_ID.'&client_secret='.SFDC_OAUTH_SECRET.'&redirect_uri='.urlencode(SFDC_OAUTH_REDIRECT_URI).'&code=');
define('SFDC_REFRESH_TOKEN_URL', SALESFORCE_HOST . 'services/oauth2/token?grant_type=refresh_token&client_id='.SFDC_OAUTH_CLIENT_ID.'&client_secret='.SFDC_OAUTH_SECRET.'&refresh_token=');

// PHP TOOLKIT
define("PARTNER_WSDL", dirname(__FILE__).'/SalesforceApi/soapclient/partner.wsdl.xml');

// ORDERING
define("ITEM_CODE", "CI_STANDARD");
define("PRICE_BOOK", "a0B3000000DD5WoEAL"); // PRODUCTION

?>